<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>原型继承实现</title>
</head>

<body>
  <script>
    // ============================== 原型继承 ==============================

    function Person(){
      eyes:2
    }
    Person.prototype.eat = function(){
      console.log('eat') 
    }

    // 男人构造函数
    function Man(){}
    // 女人构造函数
    function Woman(){}

    // 需要将Man.prototype 复制给Person 的实例对象
    Man.prototype = new Person()  //{eyes:2}
    Woman.prototype = new Person() //{eyes:2}

    // 细节处理
    Man.prototype.contructor = Man
    Woman.prototype.contructor = Woman

    // 2.继承-借助于原型对象
    const zs = new Man()
    const xh = new Woman()

    Woman.prototype.bady = function(){
      console.log('生孩子')
    }
    xh.bady()  //可以实现生孩子
    // zs.bady() //error
    console.log(zs)  
    console.log(xh)
    
    
  </script>
</body>

</html>